1. Field of the Invention
This invention relates to computer systems, more particularly to interfaces between program methods written in one language and program methods written in another language, and yet more particularly to interfaces between program methods written in a platform-independent language and program methods written in a native language in virtual machine environments.
2. Description of the Related Art
Java™ Virtual Machine (JVM)
A Java™ Virtual Machine (JVM) is a set of computer software programs and data structures which implements a specific virtual machine model. This model accepts a form of computer intermediate language, commonly referred to as Java™ bytecode, which conceptually represents the instruction set of a stack-oriented architecture. This code is most often generated by Java™ language compilers, although the JVM can also be targeted by compilers of other languages. There are many virtual machines available, both free and commercial.
Java™ Bytecode
Java™ bytecode is the form of instructions that the Java™ virtual machine (JVM) executes. Each bytecode instruction is one byte in length. The most common language targeting JVM by producing Java™ bytecode is Java™. Many compilers are available that produce Java™ bytecode. Java™ bytecode may be considered a tokenized internal representation used by the Java™ programming language.
Java™ Native Interface (JNI)
The Java™ Native Interface (JNI) is a programming framework that allows Java™ code running in a Java™ virtual machine (JVM) to call and be called by native code (code specific to a hardware and operating system platform) written in other languages, such as C, C++ and assembly. JNI may be used, for example, to write native methods (e.g., C/C++ methods) to handle situations when an application cannot be written entirely in the Java™ programming language.
JNI Stubs
The Java™ Native Interface (JNI) supports calling native code from Java™ code. These calls cross a linguistic gap, and so typically incur a higher overhead than standard Java™-to-Java™ calls. In a JVM, the steps to invoke native code from Java™ are typically encoded in low-level machine code (e.g., assembly language) stubs that are generated and specialized for each native method called. Given that conventional stubs are machine code, stubs are typically compiled by the platform-specific compiler backend. This means that stub generation has to be re-written for each platform. In addition conventional JNI stubs are not easily inlined, as inlining is typically implemented in the platform-independent front end of the compiler.
Java, JVM, and JNI are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.